<%--
*@Description 
*@Author KingTeng
*@Date 2022/3/6
*@Time 20:01
--%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" isELIgnored="false"%>
<script>
    $(function () {
        $("#loginUpButton").click(function () {
            $.post(
                "foreRegister",
                {
                    "name": $("#uname").val(),
                    "pwd": $("#upwd").val()
                },
                function (result) {
                    $("span.rerrorMessage").html("注册成功");
                    $("div.registerErrorMessageDiv").show();
                }
            )
        });

        $("input").keyup(function () {
            $("div.registerErrorMessageDiv").hide();
        });
    })

    $(function () {
        $("#loginButton").click(function () {
            $.post(
                "foreLogin",
                {
                    "name": $("#name").val(),
                    "pwd": $("#pwd").val()
                },
                function (result) {
                    if (result == "fail") {
                        $("span.errorMessage").html("用户名或密码错误");
                        $("div.loginErrorMessageDiv").show();
                    }  else{
                        window.location.href = "foreHome";
                    }

                }
            )
        });

        $("input").keyup(function () {
            $("div.loginErrorMessageDiv").hide();
        });
    })


    function keyLogin(){
        if (event.keyCode==13)  //回车键的键值为13
            document.getElementById("loginButton").click(); //调用登录按钮的登录事件
    }

    var left = window.innerWidth/2;
    $("div.loginSmallDiv").css("left",left);
</script>
<body  onkeydown="keyLogin();">
<div id="loginDiv" style="position: relative">

    <img id="loginBackgroundImg" class="loginBackgroundImg" src="${pageContext.request.contextPath}/img/site/background.png">

    <div id="loginSmallDiv" class="loginSmallDiv">
        <div class="login_acount_text">账户登录</div>
        <div class="loginInput">
            <input id="name" name="name" placeholder="账号" type="text">
        </div>
        <div class="loginInput">
            <input id="pwd" name="pwd" placeholder="密码" type="password">
        </div>

        <span class="text-danger">欢迎登录核酸检测信息统一平台</span><br><br>

        <div>
            <a href="#notImplementLink">忘记登录密码</a>
            <a href="foreToRegisterPage" class="ml-auto">免费注册</a>
        </div>

        <div>
            <button id="loginButton" class="btn btn-block redButton">登录</button>
        </div>
        <div class="loginErrorMessageDiv">
            <div class="alert alert-danger" >
                <span class="errorMessage"></span>
            </div>
        </div>
    </div>

</div>
</body>


